﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace BLL.Sec
{
    /// <summary>
    /// 节点类
    /// </summary>
    public class Node
    {
        private readonly OracleDAL.Sec.Node dal = new OracleDAL.Sec.Node();
        /// <summary>
        /// 构造方法
        /// </summary>
        public Node()
        {

        }

        #region 新增节点
        /// <summary>
        /// 创建新节点
        /// </summary>
        /// <param name="node">节点对象</param>
        /// <returns>创建是否成功</returns>
        public bool NewNode(Model.Sec.Node node)
        {
            return dal.NewNode(node);
        }
        #endregion

        #region 更新节点资料
       
        /// <summary>
        /// 最完整的更新
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public bool Update(Model.Sec.Node node)
        {
            return dal.Update(node);
        }
        #endregion

        #region 删除节点
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="NodeISN">节点ISN</param>
        /// <returns>删除是否成功</returns>
        public bool DeleteNode(string NodeISN)
        {
            return dal.DeleteNode(NodeISN);
        }
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="node">节点对象</param>
        /// <returns>删除是否成功</returns>
        public bool DeleteNode(Model.Sec.Node node)
        {
            return dal.DeleteNode(node.NodeISN);
        }
        #endregion

        /// <summary>
        /// 返回一个MODEL
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns></returns>
        public Model.Sec.Node GetModelWhere(string strWhere)
        {
            return dal.GetModelbyWhere(strWhere);
        }
        /// <summary>
        /// 返回记录数
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns></returns>
        public int GetCount(string strWhere)
        {
            return dal.GetCount(strWhere);
        }
        /// <summary>
        /// 返回一个MODEL
        /// </summary>
        /// <param name="NODEISN">节点ID</param>
        /// <returns></returns>
        public Model.Sec.Node GetModelByISN(string NODEISN)
        {

            return dal.GetModel(NODEISN);
        }
        public string  GetMaxNodeID(string strWhere)
        {
            return dal.GetMaxNodeId(strWhere);
        }
        /// <summary>
        /// 删除节点时，移动相邻节点专用
        /// </summary>
        /// <returns></returns>
        public bool DelAndMoveNode(int i, string nodeid)
        {
            return dal.DelAndMoveNode(i, nodeid);
        }
        /// <summary>
        /// 返回datatable
        /// </summary>
        /// <param name="StrWhere"></param>
        /// <returns></returns>
        public DataTable getTable(string StrWhere)
        {
            return dal.getTable(StrWhere);
        }
         /// <summary>
        /// 从sec_unit和sec_node表里根据单位的unitISN得到Node的NodeISN,NodeID,NodeName,UpnodeID,NodeLevel
        /// </summary>
        /// <param name="unitISN"></param>
        /// <returns></returns>
        public DataTable getDataTableBYUnitISN(string unitISN)
        {
            return dal.getDataTableBYUnitISN(unitISN);
        }
    }
}
